package com.company.restaurant.persistent;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;

/**
 * Created by User on 18.02.14.
 */
@Entity
@Table(name = "organization")
public class Organization implements Serializable {
    private static final long serialVersionUID = -4034790459187617239L;

    @Id
    @Column
    private Long id;

    @Column
    private String name;

    @Column
    private String prefix;

    public Organization(String name, String prefix) {
        this.name = name;
        this.prefix = prefix;
    }

    public Organization() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPrefix() {
        return prefix;
    }

    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Organization that = (Organization) o;

        if (!id.equals(that.id)) return false;
        if (!name.equals(that.name)) return false;
        if (!prefix.equals(that.prefix)) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id.hashCode();
        result = 31 * result + name.hashCode();
        result = 31 * result + prefix.hashCode();
        return result;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("Organization{");
        sb.append("id=").append(id);
        sb.append(", name='").append(name).append('\'');
        sb.append(", prefix='").append(prefix).append('\'');
        sb.append('}');
        return sb.toString();
    }
}
